const audio = document.getElementById("audio");
const playPauseBtn = document.getElementById("playPause");
const stopBtn = document.getElementById("stop");
const seekBar = document.getElementById("seekBar");
const volumeControl = document.getElementById("volumeControl");

// 播放/暂停
playPauseBtn.addEventListener("click", () => {
    if (audio.paused) {
        audio.play();
        playPauseBtn.textContent = "⏸️ 暂停";
    } else {
        audio.pause();
        playPauseBtn.textContent = "▶️ 播放";
    }
});

// 停止
stopBtn.addEventListener("click", () => {
    audio.pause();
    audio.currentTime = 0;
    playPauseBtn.textContent = "▶️ 播放";
});

// 进度条更新
audio.addEventListener("timeupdate", () => {
    seekBar.value = (audio.currentTime / audio.duration) * 100;
});

// 拖动进度条
seekBar.addEventListener("input", () => {
    audio.currentTime = (seekBar.value / 100) * audio.duration;
});

// 音量调节
volumeControl.addEventListener("input", () => {
    audio.volume = volumeControl.value;
});
